#include <stdio.h>
#include <stdlib.h>
#include "bonc_tool.h"
typedef void(F_MY_PRINT)(int pp[]);

void myPrint(int pp[])
{
    if (NULL == pp)
        return;
    int i = 0;
    for (; i < 26; ++i)
    {
        bonc_printf_In("%c : %d", 'a' + i, pp[i]);
    }
}

void fun(char *tt, int pp[], F_MY_PRINT *myprint)
{
    if (tt == NULL || pp == NULL || myprint == NULL)
        return;
    char *ptr = tt;
    int index = 0;
    while (*ptr != '\0')
    {
        index = *ptr - 'a';
        if (index >= 0 && index < 26)
        {
            ++pp[index];
        }
        ++ptr;
    }

    myPrint(pp);
}
int main()
{
    int array[26] = {0};
    char *str = "aaabbbcccddd";
    fun(str, array, myPrint);
    return 0;
}

void fun(char *tt, int pp[], F_MY_PRINT *myprint)
{
    char *ptr = NULL;
    int index = 0;

    if (NULL == tt || NULL == pp || NULL == myprint)
    {
        return;
    }

    for (ptr = tt; *ptr != '\0'; ++ptr)
    {
        index = *ptr - 'a';
        if (0 <= index && 26 > index)
        {
            ++pp[index];
        }
    }

    myPrint(pp);

    return;
}